﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Modeling.Diagrams;
using System.Drawing;

namespace UofCASE.AgileProductLinerDSL {
    public partial class TestConnector {

        protected override void InitializeInstanceResources() {
            base.InitializeInstanceResources();

            TestPortShape tPortShape = this.FromShape as TestPortShape;
            tPortShape.CollapsingChanged += OnCollapsedChangedTestConnector;
            FeaturePort fPort = this.ToShape.ModelElement as FeaturePort;
            TestShape test = this.Diagram.FindShape(fPort.Test) as TestShape;
            test.RegisterForCollapsingChangedEvent(tPortShape);

            UpdateVisibility();
        }

        protected override void OnDeleting() {
            base.OnDeleting();
            TestPortShape tPortShape = this.FromShape as TestPortShape;
            if (tPortShape == null) return;
            tPortShape.CollapsingChanged -= OnCollapsedChangedTestConnector;
            TestShape testShape = this.ToShape.ParentShape as TestShape;
            if (testShape == null) return;
            testShape.UnregisterForCollapsingChangedEvent(tPortShape);
        }

        [CLSCompliant(false)]
        protected override Microsoft.VisualStudio.Modeling.Diagrams.GraphObject.VGRoutingStyle DefaultRoutingStyle {
            get {
                return Microsoft.VisualStudio.Modeling.Diagrams.GraphObject.VGRoutingStyle.VGRouteTreeNS;
            }
        }

    }


    public partial class TestConnectorBase {
        protected Boolean GetIsVisibleDPValue() {
            TestPortShape tPortShape = this.FromShape as TestPortShape;
            if (tPortShape != null) {
                if (tPortShape.IsCollapsed) return false;
                else return true;
            } else return true;
        }
    }
}
